//
//  LoginViewController.m
//  IMChezhil
//
//  Created by zhangliucheng on 15/7/23.
//  Copyright (c) 2015年 CheZhil. All rights reserved.
//

#import "LoginViewController.h"
#import "MainViewController.h"
#import "MBProgressHUD+Add.h"
#import "IMCore.h"

@interface LoginViewController ()

@property (weak, nonatomic) IBOutlet UITextField *username;
@property (weak, nonatomic) IBOutlet UITextField *password;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"用户登录";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (IBAction)login:(id)sender {
    if (self.username.text.length == 0) {
        [MBProgressHUD showSuccess:@"请输入用户名" toView:self.view];
        return;
    }
    
    if (self.password.text.length == 0) {
        [MBProgressHUD showSuccess:@"请输入密码" toView:self.view];
        return;
    }

    [[IMCore shareInstance] loginWithUin:[NSString stringWithFormat:@"%@:%@", self.username.text, self.password.text] token:@"token" clientId:@"clientId"];
    
    MainViewController *controller = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"Main"];
    [self.navigationController pushViewController:controller animated:YES];
}

@end
